﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>邮件详情</title>
     <!--Jquery-->
    <script src="../../WF/Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>

    <!--bootstrap-->
    <link href="../../WF/Scripts/bootstrap/css/bootstrap.css" rel="Stylesheet" />
    <link href="../../WF/Scripts/bootstrap/css/font-awesome.css" rel="Stylesheet" />
    <link  href="../../WF/Scripts/bootstrap/css/css.css" type="text/css"rel="stylesheet"  media="all" />
    <script src="../../WF/Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

     <!-- 引用基础js库. -->
    <script src="../../WF/Scripts/QueryString.js" type="text/javascript" ></script>
    <script src="../../WF/Scripts/QueryString2016.js" type="text/javascript" ></script>
    <script src="../../WF/Scripts/config.js?ver=1" type="text/javascript"></script>
    <script src="../../WF/Comm/Gener.js?ver=1" type="text/javascript"></script>
    <script src="../../WF/Comm/JScript.js?ver=1" type="text/javascript"></script>
     <script src="msgComm.js" type="text/javascript"></script>

    <style type="text/css">
        /*通用*/
         body{ font-size:12px;}         
         a{ color:#124164; text-decoration:none;}
         /*数据列表*/
         table.grid{width:98%;border-collapse:collapse;}
         table.grid th{ padding:5px 5px 5px 5px; border:solid 1px #dddddd;background-color:#EEEEEE;}
         table.grid td{ padding:5px 5px 5px 5px; border:solid 1px #dddddd;}
         img{border:0px;}
       .titleInfo
       { 
            background-color:#eff5fb; 
            border-top:1px solid #fff; 
            border-bottom:1px solid #aac1de;
        }
        .label
        {
           color:#798699;
        }
        .contentInfo
        {
            border-bottom:2px solid #c1d9f3;
            }
        
    </style>

    <script type="text/javascript">

        var MyPK = GetQueryString("PKVal");

        $(function () {
            //获取信息详情
            var en = new Entity("BP.OA.Message.InBox", MyPK);
            //修改邮件的状态 已读、 阅读时间
            en.InBoxState = 1;
            if (en.OpenTime == null || en.OpenTime == undefined || en.OpenTime == "") {
                en.OpenTime = dateFtt("yyyy-MM-dd hh:mm", new Date());
                en.Update();
            }

            //解析信息
            var html = "";
            $("#title").html(en.SenderName + '|' + en.Title);
            $("#sender").html(en.SenderName + "&lt;" + en.Sender + "&gt;");

            //获取收件人的信息
            var handler = new HttpHandler("BP.OA.HttpHandler.App_Message");
            handler.AddPara("Emps", en.Receiver);
            var data = handler.DoMethodReturnString("SelectEmps");
            if (data.indexOf("err@") != -1) {
                alert(data);
                return;
            }
            data = JSON.parse(data);
            var container = $("#receviers");
            $.each(data, function (i, emp) {
                var html = "";
                if (emp.No == new WebUser().No)
                    html += "<b>我</b>";
                else
                    html += "<b>" + emp.Name + "</b>";
                html += " <span>&lt;" + emp.No + "&gt;</span>";
                html += "<span class='semicolon'>;</span>";
                if (emp.No == new WebUser().No)
                    container.prepend(html);
                else
                    container.append(html);
            });

            //获取抄送人的信息
            var ccers = en.CCers;
            if (ccers == null || ccers == "" || ccers == undefined)
                return;
            handler.AddPara("Emps", en.CCers);
            var data = handler.DoMethodReturnString("SelectEmps");
            if (data.indexOf("err@") != -1) {
                alert(data);
                return;
            }

            data = JSON.parse(data);
            container = $("#ccers");

            $.each(data, function (i, emp) {
                var html = "";
                if (emp.No == new WebUser().No)
                    html += "<b>我</b>";
                else
                    html += "<b>" + emp.Name + "</b>";
                html += " <span>&lt;" + emp.No + "&gt;</span>";
                html += "<span class='semicolon'>;</span>";
                if (emp.No == new WebUser().No)
                    container.prepend(html);
                else
                    container.append(html);
            });

            //发送时间
            //时间格式转化为年月日
            var sendTime = en.SendTime;
            var ttDate = sendTime.replace(/(\d{4}).(\d{1,2}).(\d{1,2}).+/mg, '$1年$2月$3日') + sendTime.substring(10);
            $("#sendTime").html(ttDate + "(" + getWeekDay(sendTime) + ")");
            $("#docs").html(en.Docs);

        });

      
      //返回
      function Back() {
          window.location.href = 'InBox.htm';
      }

      //回复
      function ReplyMsg() {
          window.location.href = 'SendMsg.htm?ResourceType=0&PKVal=' + MyPK;
      }

      //转发
      function ForwardedMsg() {
          window.location.href = 'SendMsg.htm?ResourceType=1&PKVal=' + MyPK;
      }

      function NoChangSendMsg() {
          //弹出提示窗口，输入接收人
          $("#myModal").modal('show');
      }

      //删除邮件
      function Delete() {
          var en = new Entity("BP.OA.Message.InBox", MyPK);
          //转入到垃圾箱
          en.InBoxState = 2
          en.Update();
          
          alert("删除成功");
      }
      function Send() {
          //获取信息详情
          var en = new Entity("BP.OA.Message.InBox", MyPK);
          recevier = $("#TB_Recevier").val();
          if (receviers.indexOf(';') != -1) {
              $("#msg").html("一次只能转发给一人");
              return;
          }

          //邮件信息
          var sendEn = new Entity("BP.OA.Message.SendBox");
          sendEn.Title = en.Title;
          sendEn.Sender = en.Sender;
          sendEn.SenderName = en.SenderName;
          sendEn.Doc = en.Doc;
          sendEn.IsSend = 1; //未发送进草稿箱
          sendEn.Receiver = recevier;
          sendEn = sendEn.Insert();
          if (sendEn == 0) {
              return;
          }
          //获取接受者信息
        en = new Entity("BP.OA.Message.InBox");
        en.Sender = sendEn.Sender;
        en.SenderName = sendEn.SenderName;
        en.Receiver = sendEn.Receiver;
        en.SendTime = sendEn.SendTime;
        en.Title = sendEn.Title;
        en.Docs = sendEn.Docs;
        en.MyPK = sendEn.MyPK + "_" + recevier;
        en.UserNo = recevier;
        en.RefMsg = sendEn.MyPK;
        en.InBoxState = 0;
        en.MsgType = 0;
        en.Save();      
        
      }
      function Close() {
          $("#myModal").modal('hide');
      }
      //作为附件转发
      function ForwardedFileMsg() {
          window.location.href = 'SendMsg.htm?ResourceType=2&PKVal=' + MyPK;
      }
    </script>

</head>
<body>
<div id="alls" style="">
    <div style="background-color:#eff5fb">
    <div style="margin-left:30px;margin-top:10px">
        <div class="btn-group">
             <button type="button" class="btn btn-default " onclick="ReplyMsg()">回复</button>
        </div>
        <div class="btn-group">
	        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > 
		       转发 <span class="caret"></span>
	        </button>
	        <ul class="dropdown-menu" role="menu">
		        <li><a href="javaScript:void(0);" onclick="ForwardedMsg()">转发</a></li>
		        <li><a href="javaScript:void(0);" onclick="NoChangSendMsg()">原文件转发</a></li>
	        </ul>
        </div>
        <div class="btn-group">
             <button type="button" class="btn btn-default " onclick="Delete()">删除</button>
        </div>
        <br />
    </div>
    <div id="InBoxMsg" style="margin-left:30px;margin-top:10px;">
         <!--显示邮件信息-->
        <div class="titleInfo">
            <div style="text-align: left; padding-left: 10px; margin-bottom:10px;">
                <div style="float: left;"><span class="label"></span></div>
                <div style="float: left; padding: 1px 1px 1px 1px; width: 80%;height:17px; overflow:visible;">
                     <p  id='title' style="font-size: 16px; font-weight: bolder; ">1111111111</p>
                </div>
                <div style="clear: both;"></div>
            </div>
             <div style="text-align: left; padding-left: 10px; margin-bottom:5px;">
                <div style="float: left;"><span class="label">发件人：</span></div>
                <div id="sender" style="float: left; padding: 1px 1px 1px 1px; width: 80%;height:17px; overflow:visible;"> zhoupeng</div>
                <div style="clear: both;"></div>
            </div>
            <div style="text-align: left; padding-left: 10px; margin-bottom:5px;">
                <div style="float: left;"><span class="label">收件人：</span></div>
                <div id="receviers" style="float: left; padding: 1px 1px 1px 1px; width: 80%;height:17px; overflow:visible;"> zhoupeng</div>
                <div style="clear: both;"></div>
            </div>
            <div style="text-align: left; padding-left: 10px; padding-bottom:5px;">
                <div style="float: left;"><span class="label">抄送人：</span></div>
                <div id="ccers" style="float: left; padding: 1px 1px 1px 1px; width: 80%;height:17px; overflow:visible;">zhoupeng</div>
                <div style="clear: both;"></div>
            </div>
            <div style="text-align: left; padding-left: 10px; padding-bottom:10px;">
                <div style="float: left;"><span class="label">发送时间：</span></div>
                <div id="sendTime" style="float: left; padding: 1px 1px 1px 1px; width: 80%;height:17px; overflow:visible;">2018年09月14日 11:17</div>
                <div style="clear: both;"></div>
            </div>
         </div>
        </div>
    </div>
    <div class="contentInfo" style="margin-left:30px">
            <div id="docs" class="Article" style="margin: 10x 10px 10px 10px; padding: 10px 10px 10px 10px; border: dashed 1px #dddddd;min-height:300px;"></div>
      </div>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					原信转发
				</h4>
			</div>
			<div class="modal-body">
				<label for="TB_Recevier">发件人：</label>
                <input  type="text"" id="TB_Recevier" name="TB_Recevier" class="form-control" />
                <span id="msg"></span>
			</div>
			<div class="modal-footer">
                <span style="margin-right: 300px;">提示：原信转发不能退回</span>
				<button type="button" class="btn btn-default" data-dismiss="modal" onclick="Send()">
                    发送
				</button>
				<button type="button" class="btn btn-primary" onclick="Close()">
					取消
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>


</body>
</html>
